home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group00a.txt
/
000014_icon-group-sender _Thu Jan 20 17:06:44 2000.msg
< prev
next >
Wrap
Internet Message Format
|
2001-01-03
|
2KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id RAA23952
for icon-group-addresses; Thu, 20 Jan 2000 17:06:34 -0700 (MST)
Message-Id: <200001210006.RAA23952@baskerville.CS.Arizona.EDU>
X-Authentication-Warning: agate.berkeley.edu: news set sender to <news> using -f
From: espie@liafa.jussieu.fr (Marc Espie)
X-Newsgroups: comp.lang.icon
Subject: Re: Question
Date: 20 Jan 2000 20:22:46 GMT
X-Trace: vishnu.jussieu.fr 948399766 688 132.227.81.128 (20 Jan 2000 20:22:46 GMT)
X-Complaints-To: Newsmaster@jussieu.fr.
X-Newsreader: trn 4.0-test70 (17 January 1999)
To: icon-group@optima.CS.Arizona.EDU
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
In article <200001201933.MAA09251@baskerville.CS.Arizona.EDU>,
Steve Graham <Steve_Graham@labcorp.com> wrote:
>I need a program which generates all combinations (or permutations?) of
>12345, i.e. 12345, 12354, 12435, etc I have a hunch that Icon has built
>in facilities to accomplish this, but I haven't figured out what they
>are. Any suggestions?
If you don't need to build them in lexicographic order, this is easily
achieved with a recursive generator.
Try this:
procedure permute(l, i)
if i >= *l then
return l
else
suspend l[i to *l] <-> l[i] & permute(l, i+1)
end
procedure write_list(l)
every writes(!l, " ")
write()
end
procedure main()
every write_list(permute(["a", "b", "c"], 1))
end
--
Marc Espie
|anime, sf, juggling, unicycle, acrobatics, comics...
|AmigaOS, OpenBSD, C++, perl, Icon, PostScript...
| `real programmers don't die, they just get out of beta'